package camid.distribution.events;

import java.util.Observer;

import camid.distribution.activeobject.ObjectRegistry;
import camid.distribution.activeobject.ObjectScheduler;
import camid.distribution.activeobject.ProxyBuilder;

public class MainEventHandler {

	private ObjectScheduler scheduler;
	
	public static final String MAIN_EVENT_HANDLER = "MainEventHanlder";
	
	public MainEventHandler(ObjectRegistry registry) 
	{
		EventHandler mainHandler = new EventHandler(MAIN_EVENT_HANDLER);
		scheduler = new ObjectScheduler(MAIN_EVENT_HANDLER, mainHandler);
		registry.add(scheduler);
	}

	public FutureNotificator getFutureNotificator() {
		ProxyBuilder<FutureNotificator> builder = 
			new ProxyBuilder<FutureNotificator>(FutureNotificator.class, scheduler);
		FutureNotificator notificator = builder.newProxy();
		return notificator;
	}

	public ObjectScheduler getScheduler() {
		return scheduler;
	}
	
	public void registerObserver( Observer observer )
	{
		EventHandler channel = (EventHandler)this.scheduler.getEntity();
		channel.registerObserver(observer);
	}
	
	
}
